﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/MasterPage.Master" AutoEventWireup="true" CodeBehind="ManagePackages.aspx.cs" Inherits="DrivingCRM.Views.Private.CRM.ManagePackages" %>
<asp:Content ID="Content1" ContentPlaceHolderID="title" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="banniere" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="nav" runat="server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="contenu" runat="server">
    <h2>Gestion des Paquetages:</h2>
    <asp:UpdatePanel ID="UP_Global" runat="server">
        <ContentTemplate>
            <%-- List des éléments à gérer --%>
            <asp:ListView ID="LV_Packages" runat="server" DataKeyNames="IdPackage" 
                DataSourceID="DS_Packages" GroupItemCount="1" InsertItemPosition="None"
                OnItemCanceling="LV_Packages_ItemCanceling">
                <%-- Template de la ligne alternative --%>
                <AlternatingItemTemplate>
                    <td runat="server" style="background-color:#FFF8DC;">
                        <table class="Table_ItemList">
                            <tr>
                                <td>Nom du paquetage:</td>
                                <td><asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' /></td>
                            </tr>
                            <tr>
                                <td>Description:</td>
                                <td><asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' /></td>
                            </tr>
                            <tr>
                                <td>Prix:</td>
                                <td><asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>' /></td>
                            </tr>
                            <tr>
                                <td><asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Supprimer" OnClientClick="return confirm('Confirmez-vous la suppression de ce paquetage ?');" /></td>
                                <td><asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Modifier" /></td>
                            </tr>
                        </table>                        
                        <%--Products:
                        <asp:Label ID="ProductsLabel" runat="server" Text='<%# Eval("Products") %>' />--%>
                    </td>
                </AlternatingItemTemplate>

                <%-- Template de modification --%>
                <EditItemTemplate>
                    <td runat="server" style="background-color:#008A8C;color: #FFFFFF;">
                        <table class="Table_ItemList">
                            <tr>
                                <td>Nom du paquetage:</td>
                                <td><asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' /></td>
                            </tr>
                            <tr>
                                <td>Description:</td>
                                <td><asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' /></td>
                            </tr>
                            <tr>
                                <td>Prix:</td>
                                <td><asp:TextBox ID="PriceTextBox" runat="server" Text='<%# Bind("Price") %>' /></td>
                            </tr>
                            <tr>
                                <td><asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Mettre à jour" /></td>
                                <td><asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Annuler" /></td>
                            </tr>
                        </table>
                    </td>
                </EditItemTemplate>

                <%-- Template de liste vide --%>
                <EmptyDataTemplate>
                    <table runat="server" 
                        style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;" class="Table_ItemList">
                        <tr>
                            <td>
                                Aucun paquetage en base.</td>
                        </tr>
                        <tr>
                            <td><asp:Button ID="B_AddPackage" runat="server" Text="Ajouter un paquetage" OnClick="B_Addpackage_Click" /></td>
                        </tr>
                    </table>
                </EmptyDataTemplate>

                <%-- Template utilisé pour complété les éléments vides d'un regroupement --%>
                <EmptyItemTemplate>
                    <td runat="server" class="Table_ItemList" />
                </EmptyItemTemplate>

                <%-- Template de groupage d'objet --%>
                <GroupTemplate>
                    <tr ID="itemPlaceholderContainer" runat="server">
                        <td ID="itemPlaceholder" runat="server">
                        </td>
                    </tr>
                </GroupTemplate>

                <%-- Template d'insertion d'objet --%>
                <InsertItemTemplate>
                    <td runat="server">
                        <table class="Table_ItemList">
                            <tr>
                                <td>Nom du paquetage:</td>
                                <td><asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' /></td>
                            </tr>
                            <tr>
                                <td>Description:</td>
                                <td><asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' /></td>
                            </tr>
                            <tr>
                                <td>Prix:</td>
                                <td><asp:TextBox ID="PriceTextBox" runat="server" Text='<%# Bind("Price") %>' /></td>
                            </tr>
                            <tr>
                                <td><asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insérer" /></td>
                                <td><asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Annuler" /></td>
                            </tr>
                        </table>
                    </td>
                </InsertItemTemplate>

                <%-- Template d'objet --%>
                <ItemTemplate>
                    <td runat="server" style="background-color:#DCDCDC;color: #000000;">
                        <table class="Table_ItemList">
                            <tr>
                                <td>Nom du paquetage:</td>
                                <td><asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' /></td>
                            </tr>
                            <tr>
                                <td>Description:</td>
                                <td><asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' /></td>
                            </tr>
                            <tr>
                                <td>Prix:</td>
                                <td><asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>' /></td>
                            </tr>
                            <tr>
                                <td><asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Supprimer" OnClientClick="return confirm('Confirmez-vous la suppression de ce paquetage ?');" /></td>
                                <td><asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Modifier" /></td>
                            </tr>
                        </table>                        
                        <%--Products:
                        <asp:Label ID="ProductsLabel" runat="server" Text='<%# Eval("Products") %>' />--%>
                    </td>
                </ItemTemplate>

                <%-- Conteneur racine du ListView --%>
                <LayoutTemplate>
                    <table runat="server" width="80%">
                        <%-- Ligne contenant les éléments de la liste --%>
                        <tr runat="server">
                            <td runat="server">
                                <table ID="groupPlaceholderContainer" runat="server" border="1" 
                                    style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;" width="100%">
                                    <tr ID="groupPlaceholder" runat="server">
                                    </tr>
                                </table>
                            </td>
                        </tr>

                        <%-- Ligne contenant le bouton d'affichage de la ligne d'ajout d'un package --%>
                        <tr runat="server">
                            <td runat="server">
                                <asp:Button ID="B_DisplayInsert" runat="server" Text="Ajouter un paquetage" OnClick="B_Addpackage_Click" />
                            </td>
                        </tr>

                        <%-- Ligne contenant le pager --%>
                        <tr runat="server">
                            <td runat="server" 
                                style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
                                <asp:DataPager ID="DataPager1" runat="server" PageSize="5">
                                   <Fields>
                                        <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                            ShowNextPageButton="False" ShowPreviousPageButton="False" PreviousPageText="Précédent" FirstPageText="Première page" />
                                        <asp:NumericPagerField />
                                        <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
                                            ShowNextPageButton="False" ShowPreviousPageButton="False" NextPageText="Suivant" LastPageText="Dernière page" />
                                    </Fields>
                                </asp:DataPager>
                            </td>
                        </tr>
                    </table>
                </LayoutTemplate>                
            </asp:ListView>

            <%-- Datasource lié au modèle Entity Framework --%>
            <asp:EntityDataSource ID="DS_Packages" runat="server" 
                ConnectionString="name=Model_DrivingCRMContainer" 
                DefaultContainerName="Model_DrivingCRMContainer" EnableDelete="True" 
                EnableFlattening="False" EnableInsert="True" EnableUpdate="True" 
                EntitySetName="PackageSet1" EntityTypeFilter="Package">                
            </asp:EntityDataSource>
        </ContentTemplate>
    </asp:UpdatePanel>

    <%--<asp:UpdatePanel ID="UP_Detail" runat="server">
        <ContentTemplate>
        
        </ContentTemplate>
    </asp:UpdatePanel>--%>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="footer" runat="server">
</asp:Content>
